package values.skill
{
	import core.manager.battle.BattleCountManager;
	import core.manager.battle.BattleEffectManager;
	
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	import values.avatar.IAvatarValue;
	
	public class BaseDamageValue extends EventDispatcher implements IDamageEffectValue
	{
		public function BaseDamageValue()
		{
			super();
		}
		
		public function get damage():Number
		{
			return _damage;
		}
		
		public function get kill():Boolean
		{
			return _kill;
		}
		
		private var _owner:IAvatarValue;
		
		private var _hitter:IAvatarValue;
		
		private var _skillValue:SkillValue;
		
		public function init(owner:IAvatarValue, hitter:IAvatarValue, skillValue:SkillValue):void
		{
			_owner = owner;
			_hitter = hitter;
			_skillValue = skillValue;
		}
		
		private var _damage:Number;
		
		private var _kill:Boolean = false;
		
		public function effect():void
		{
			var obj:* = BattleCountManager.countSkillBaseDamage(_owner , _hitter , _skillValue);
			_damage = obj.data;
			_damage = SkillNumTypeKey.getResult(SkillNumTypeKey.PERCENTAGE, _damage,_skillValue.getLevelValueByTag(_skillValue.template.baseDamageValue.baseNum));
			obj.data = _damage;
			_hitter.hp -= _damage;
			if(_hitter.hp <= 0) _kill = true;
			BattleEffectManager.showDamageEffect(_owner , _hitter , obj);
		}
		
		public function dispose():void
		{
			_owner = null;
			_hitter = null;
			_skillValue = null;
		}
	}
}